package com.ruoyi.zhongkao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zhongkao.domain.ZkCandidateType;
import com.ruoyi.zhongkao.service.IZkCandidateTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 考生类型Controller
 * 
 * @author ruoyi
 * @date 2025-07-04
 */
@Api(tags = "中考-考生类型管理")
@RestController
@RequestMapping("/zhongkao/candidateType")
public class ZkCandidateTypeController extends BaseController
{
    @Autowired
    private IZkCandidateTypeService zkCandidateTypeService;


    @GetMapping("/all")
        @ApiOperation("中考考生类型管理 - 查询所有数据")
    public AjaxResult getAll()
        {
        return success(zkCandidateTypeService.selectZkCandidateTypeAll());
    }
    /**
     * 查询考生类型列表
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:type:list')")
    @GetMapping("/list")
        @ApiOperation("中考考生类型管理 - 分页查询列表")
    public TableDataInfo list(ZkCandidateType zkCandidateType)
    {
        startPage();
        List<ZkCandidateType> list = zkCandidateTypeService.selectZkCandidateTypeList(zkCandidateType);
        return getDataTable(list);
    }

    /**
     * 导出考生类型列表
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:type:export')")
    @Log(title = "考生类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
        @ApiOperation("中考考生类型管理 - 导出数据")
    public void export(HttpServletResponse response, ZkCandidateType zkCandidateType)
    {
        List<ZkCandidateType> list = zkCandidateTypeService.selectZkCandidateTypeList(zkCandidateType);
        ExcelUtil<ZkCandidateType> util = new ExcelUtil<ZkCandidateType>(ZkCandidateType.class);
        util.exportExcel(response, list, "考生类型数据");
    }

    /**
     * 获取考生类型详细信息
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:type:query')")
    @GetMapping(value = "/{id}")
        @ApiOperation("中考考生类型管理 - 根据ID获取详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zkCandidateTypeService.selectZkCandidateTypeById(id));
    }

    @GetMapping(value = "/selectByCode/{code}")
        @ApiOperation("中考考生类型管理 - getCode")
    public AjaxResult getCode(@PathVariable("code") String code)
        {
        return success(zkCandidateTypeService.selectZkCandidateTypeByCode(code));
    }
    /**
     * 新增考生类型
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:type:add')")
    @Log(title = "考生类型", businessType = BusinessType.INSERT)
    @PostMapping
        @ApiOperation("中考考生类型管理 - 新增数据")
    public AjaxResult add(@RequestBody ZkCandidateType zkCandidateType)
    {
        return toAjax(zkCandidateTypeService.insertZkCandidateType(zkCandidateType));
    }

    /**
     * 修改考生类型
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:type:edit')")
    @Log(title = "考生类型", businessType = BusinessType.UPDATE)
    @PutMapping
        @ApiOperation("中考考生类型管理 - 修改数据")
    public AjaxResult edit(@RequestBody ZkCandidateType zkCandidateType)
    {
        return toAjax(zkCandidateTypeService.updateZkCandidateType(zkCandidateType));
    }

    /**
     * 删除考生类型
     */
    @PreAuthorize("@ss.hasPermi('zhongkao:type:remove')")
    @Log(title = "考生类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
        @ApiOperation("中考考生类型管理 - 删除数据")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zkCandidateTypeService.deleteZkCandidateTypeByIds(ids));
    }
}
